package com.zcn.io.web.controller;

import com.zcn.io.web.service.PayDetailService;
import com.zcn.io.common.entity.PayDetail;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.zcn.io.common.pojo.CommonResult;
import com.zcn.io.common.vo.PayDetailTotalVo;

import java.util.List;

/**
 * @author: 202438 邱建伟
 * @date: 2024/9/22 15:58
 */
@RestController
@AllArgsConstructor
@RequestMapping("/payDetail")
public class PayDetailController {

    private final PayDetailService payDetailService;

    @GetMapping("/listAllByParentId")
    private CommonResult<List<PayDetail>> listAllByParentId(String orderId) {
        return CommonResult.success(this.payDetailService.listAllByOrderId(orderId));
    }

    @PostMapping("/save")
    private CommonResult<String> save(@RequestBody PayDetail payDetail) {
        payDetailService.save(payDetail);
        return CommonResult.success("保存成功");
    }

    @PostMapping("/updateById")
    private CommonResult<String> updateById(@RequestBody PayDetail payDetail) {
        payDetailService.updateById(payDetail);
        return CommonResult.success("更新成功");
    }

    @DeleteMapping("/deleteById")
    private CommonResult<String> deleteById(String id) {
        payDetailService.deleteById(id);
        return CommonResult.success("删除成功");
    }



}
